/*
 * Dispatcher.cpp
 *
 *  Created on: 2012-5-18
 *      Author: WuyaMony
 */

#include "Dispatcher.h"

namespace my {

Dispatcher::Dispatcher() {

}
void Dispatcher::simulate(deque<int> &data) {
	Adder adder(data);
	Clock clock(data, adder);
	cout<<"simulate"<<endl;
	while (data.size() > 1 || adder.getTaskNum()>0) {
		cout<<"tick: "<<clock.getTimeCost()+1<<" ";
		clock.Tick();
		adder.Tick();
		cout<<" Tasknum: "<<adder.getTaskNum()<<" Data: "<<data.size()<<endl;
	}
	cout<<"time cost :"<<clock.getTimeCost()<<endl;
}
void Dispatcher::mul_sim() {
	srand(time(0));
	deque<int> data;
	for (int n = 4; n <= 15; ++n) {
		cout<<"n="<<n<<endl;
		data.clear();
		for (int j = 0; j < n; ++j) {
			data.push_back(rand());
			cout<<"add "<<data.back()<<endl;
		}
		simulate(data);
	}
}
}

/* namespace my */
